package cn.zyl.demo.undertow.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * UndertowIndexServlet类说明:
 *
 * @author z.y.l
 * @version v1.0
 * @date 2020-09-09
 */
//@WebServlet(name = "IndexServlet",urlPatterns = "/indexServlet")
public class UndertowIndexServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
//        super. doGet(req, resp);
        String name = "zyl-servlet";
        name = new String(name.getBytes(req.getCharacterEncoding()), StandardCharsets.UTF_8);
        req.setAttribute("name", name);
        resp.sendRedirect("/index");
    }
}
